<%@ page import="com.situ.web.entity.Student" %>
<%@ page import="org.w3c.dom.stylesheets.LinkStyle" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.sun.xml.internal.ws.client.sei.SEIStub" %><%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2021/8/20
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%--EL作用从域对象中取出数据--%>
    <%
        // HttpServelteRequest request = new HttpServelteRequest();
        // ServletContext application = new ServletContext();
        // pageContext、request、session、application
        // 1、普通字符串
        pageContext.setAttribute("name", "lisi");
        request.setAttribute("name", "zhangsan");
        // 2、Student对象
        Student student = new Student(1, "王五", 23, "男");
        session.setAttribute("student", student);
        // 3、List集合
        Student student1 = new Student(1, "王五1", 23, "男");
        Student student2 = new Student(2, "王五2", 23, "男");
        Student student3 = new Student(3, "王五3", 23, "男");
        List<Student> list = new ArrayList<>();
        list.add(student1);
        list.add(student2);
        list.add(student3);
        application.setAttribute("stuList", list);
    %>

    <%--1、普通字符串--%>
    <%--使用JSP表达式--%>
    <%=pageContext.getAttribute("name")%><br/>
    <%=request.getAttribute("name")%><br/>
    <%--、EL表达式--%>
    ${pageScope.name}<br/>
    ${requestScope.name}<br/>
    ${name}<br/>
    <hr/>

    <%--2、获取对象--%>
    <%--使用JSP表达式--%>
    <%=session.getAttribute("student")%><br/>
    <%
       Student stu = (Student) session.getAttribute("student");
    %>
    <%=stu.getId()%>--<%=stu.getName()%> <br/>
    <%--EL表达式--%>
    ${student} <br/>
    ${student.id} <br/>
    ${student.name} <br/>

    <hr/>
    <%--List<Student>--%>
    <%--使用JSP表达式--%>
    <%
        List<Student> stuList = (List<Student>) application.getAttribute("stuList");
    %>
    <%=stuList.get(0).getName()%> <br/>
    <%--EL表达式--%>
    ${stuList}<br/>
    ${stuList[0].name}

    <hr/>
    <%=request.getContextPath()%> <br/>
    ${pageContext.request.contextPath}
</body>
</html>
